<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>学生详细信息</title>
    <script th:src="@{../js/jquery-3.1.1.min.js}"></script>
</head>

<!-- 为了在js中使用thymeleaf -->
<script th:inline="javascript">
//将下拉框和复选框进行选中
function onload(){
	//在js中引用thymeleaf的语法

	var sex = [[${userModel.student.sex}]];  

	document.getElementById("sex").value =sex;

	var room_id=[[${userModel.student.room_id}]];

	document.getElementById("room_id").value=room_id;

    var course_id=[[${userModel.student.course_id}]];

    document.getElementById("course_id").value=course_id;

    var ids=[[${userModel.ids}]];
	var Tids=ids.split(",")
	for (var i=0;i<Tids.length;i++){
        $("input:checkbox[value='"+Tids[i]+"']").attr("checked","checked");
	}

}

</script>
<body onload="onload()">
<form action="/user" method="post" th:object="${userModel.student}">
<input type="hidden" name="id" th:value="*{id}" />
姓名:<input type="text" placeholder="姓名" name="name" th:value="*{name}" /></br>
年龄:<input type="text" placeholder="年龄" name="age" th:value="*{age}" /></br>
手机号:<input type="text" placeholder="手机号" name="tel" th:value="*{tel}" /></br>
性别:<select name="sex" th:value="*{sex}" id="sex">
	<option value="男">男</option>
	<option value="女">女</option>
</select>
班级:<select name="room_id" th:value="*{room_id}" id="room_id">
	<option value="1">2班</option>
	<option value="2">3班</option>
</select>
选课:<select name="course_id" th:value="*{course_id}" id="course_id">
	<option value="1">语文</option>
	<option value="2">数学</option>
	<option value="3">英语</option>
</select><br>
选择老师:<input class="tea" type="checkbox" name="teacherIds"  th:each="teacher : ${userModel.teachers}"
		th:value="${teacher.id}" th:text="${teacher.name}"/><br>
<input type="submit" value="修改"/> <input style="margin-left:30px" type="button" value="取消"/>

</form>


</body>
</html>